﻿using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;

#nullable disable

namespace LCS.Domain.EF
{
    public partial class hds150188412_dbContext : DbContext
    {
        public hds150188412_dbContext()
        {
        }

        public hds150188412_dbContext(DbContextOptions<hds150188412_dbContext> options)
            : base(options)
        {
        }

        public virtual DbSet<XPage> XPages { get; set; }
        public virtual DbSet<XPlugin> XPlugins { get; set; }
        public virtual DbSet<XRole> XRoles { get; set; }
        public virtual DbSet<XSetting> XSettings { get; set; }
        public virtual DbSet<XUser> XUsers { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            if (!optionsBuilder.IsConfigured)
            {
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263.
                optionsBuilder.UseSqlServer("Data Source=hds150188412.my3w.com; Initial Catalog=hds150188412_db; Persist Security Info=True; User ID=hds150188412; Password=Sunjie@3197!@#;");
            }
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.HasAnnotation("Relational:Collation", "Chinese_PRC_CI_AS");

            modelBuilder.Entity<XPage>(entity =>
            {
                entity.HasKey(e => e.UID);

                entity.ToTable("XPage");

                entity.Property(e => e.UID).ValueGeneratedNever();

                entity.Property(e => e.CreateTime).HasColumnType("datetime");

                entity.Property(e => e.DisplayTime).HasColumnType("datetime");

                entity.Property(e => e.Enabled)
                    .IsRequired()
                    .HasDefaultValueSql("((1))");

                entity.Property(e => e.UpdateTime).HasColumnType("datetime");

                entity.Property(e => e.Visible)
                    .IsRequired()
                    .HasDefaultValueSql("((1))");

                entity.Property(e => e.XAction).HasMaxLength(200);

                entity.Property(e => e.XContent).HasColumnType("ntext");

                entity.Property(e => e.XController).HasMaxLength(200);
            });

            modelBuilder.Entity<XPlugin>(entity =>
            {
                entity.HasKey(e => e.UID)
                    .HasName("PK_XPlugins");

                entity.ToTable("XPlugin");

                entity.Property(e => e.UID).ValueGeneratedNever();
            });

            modelBuilder.Entity<XRole>(entity =>
            {
                entity.HasKey(e => e.UID)
                    .HasName("PK_XTemplate");

                entity.ToTable("XRole");

                entity.Property(e => e.UID).ValueGeneratedNever();
            });

            modelBuilder.Entity<XSetting>(entity =>
            {
                entity.HasKey(e => e.UID)
                    .HasName("PK_XSettings");

                entity.ToTable("XSetting");

                entity.Property(e => e.UID).ValueGeneratedNever();

                entity.Property(e => e.CreateTime).HasColumnType("datetime");

                entity.Property(e => e.Remark).HasColumnType("ntext");

                entity.Property(e => e.UpdateTime).HasColumnType("datetime");

                entity.Property(e => e.XKey)
                    .IsRequired()
                    .HasMaxLength(200);

                entity.Property(e => e.XName)
                    .IsRequired()
                    .HasMaxLength(200);

                entity.Property(e => e.XValue).IsRequired();
            });

            modelBuilder.Entity<XUser>(entity =>
            {
                entity.HasKey(e => e.UID);

                entity.ToTable("XUser");

                entity.Property(e => e.UID).ValueGeneratedNever();

                entity.Property(e => e.XUserName).HasMaxLength(100);

                entity.Property(e => e.XUserPwd).HasMaxLength(100);
            });

            OnModelCreatingPartial(modelBuilder);
        }

        partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
    }
}
